{% extends "./admin/layout.html" %}
{% block title %}管理文章{% endblock %}
{% block head %}
    {{ super() }}
{% endblock %}
{% block content %}
    <div class="row" style="margin: 100px 200px 0px 200px;">
        <div class="col-md-5">
            {% block nav %}
                {{ super() }}
            {% endblock %}
        </div>
        <div class="col-md-7">
            {% if posts %}
                <table class="table">
                <thead>
                <tr>
                    <th>文章标题</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                {% for post in posts %}
                    <tr>
                        <td>{{ post.title }}</td>
                        <td><a href="./del/{{ post.id }}">删除</a>--<a href="./modify/{{ post.id }}/">修改</a></td>
                    </tr>
                {% endfor %}
                </tbody>
            {% else %}
                <div class="alert alert-warning with-icon">
                    <i class="icon-frown"></i>
                    <div class="content">没有记录！</div>
                </div>
            {% endif %}
            </table>
            <footer>
                <ul class="pager">
                    {% if pagination.has_prev %}
                        <li class="previous">
                            <a href="{{ url_for('.admin_article',page=pagination.page-1) }}">« 上一页</a>
                        </li>
                    {% else %}
                        <li class="previous disabled">
                            <a href="#">« 上一页</a>
                        </li>
                    {% endif %}

                    {% for p in pagination.iter_pages() %}
                        {% if pagination.page == p %}
                            <li class="active"><a href="{{ url_for('.admin_article',page=p) }}">{{ p }}</a></li>
                            </span>
                        {% else %}
                            <li><a href="{{ url_for('.admin_article',page=p) }}">{{ p }}</a></li>
                        {% endif %}
                    {% endfor %}
                    {% if pagination.has_next %}
                        <li class="next">
                            <a href="{{ url_for('.admin_article',page=pagination.page+1) }}">下一页 »</a>
                        </li>
                    {% else %}
                        <li class="next disabled">
                            <a href="#">下一页 »</a>
                        </li>
                    {% endif %}
                </ul>
            </footer>
        </div>
    </div>
{% endblock %}